﻿Imports System.Data.OleDb
Imports System.Data

Partial Class Main_UploadLink
    Inherits System.Web.UI.Page

    Protected Sub btnPost_Click(sender As Object, e As System.EventArgs) Handles btnPost.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("myFirstDatabase").ConnectionString)
        oleDbConn.Open()
        Dim LinkViewSql As String = "INSERT INTO tblLinks(Neighbor,Link,Notes,SubmittedDate) VALUES(@f1,@f2,@f3,@f4)"
        Dim cmd As OleDbCommand = New OleDbCommand(LinkViewSql, oleDbConn)
        cmd.CommandType = CommandType.Text
        Dim SubmittedDate As DateTime = Now()
        Dim format As String = "ddd MMM yyyy"
        cmd.Parameters.AddWithValue("@f1", User.Identity.Name)
        cmd.Parameters.AddWithValue("@f2", txtLink.Text)
        cmd.Parameters.AddWithValue("@f3", txtDescription.Text)
        cmd.Parameters.AddWithValue("@f4", SubmittedDate.ToString(format))
        cmd.ExecuteNonQuery()
        Response.Redirect("../Main/UploadSuccess.aspx")
    End Sub
End Class
